package com.wm.eduService.controller;


import com.wm.commonutils.R;
import com.wm.eduService.entity.subject.OneSubject;
import com.wm.eduService.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author sshdg
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/eduService/subject")
//@CrossOrigin
@Api(tags = "课程分类管理")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    @PostMapping("/addSubject")
    @ApiOperation("上传Excel添加科目")
    public R addSubject(MultipartFile file){

        //上传过来的excel文件
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }
    @ApiOperation("获取所有分类")
    @GetMapping("/findAllSubject")
    public R findAllSubject(){
        List<OneSubject> allOneAndTwoSubject = eduSubjectService.getAllOneAndTwoSubject();

        return R.ok().data("items",allOneAndTwoSubject);
    }

}

